#include<bits/stdc++.h>
using namespace std;
int n,m,l,v,t,d[100009],u[100009],a[100009],csy[100009],num,ans;
set<int>s[100009];
int h[100009];
void dfs(int i,int sum,int number){
    if(number>=num)return ;
    if(sum==ans){
        num=min(num,number);
        return ;
    }
    for(int j=i+1;j<=m;j++){
            int answer=0;
            for(auto x:s[j]){
                if(h[x]==0)
                    answer++;
                    h[x]++;
            }
            if(answer)dfs(j,sum+answer,number+1);
            for(auto x:s[j])
                    h[x]--;
    }
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","r",stdout);
    cin>>t;
    while(t--){
        cin>>n>>m>>l>>v;
        for(int i=1;i<=n;i++)
            cin>>d[i]>>u[i]>>a[i];
        for(int i=1;i<=m;i++)
            cin>>csy[i];
        num=m,ans=0;
        for(int i=1;i<=m;i++)s[i].clear();
        for(int i=1;i<=n;i++){
            if(a[i]==0){
                if(u[i]>v){
                    int l=lower_bound(csy+1,csy+1+m,d[i])-csy;
                    if(csy[l]>=d[i]){
                        ans++;

                        for(int j=l;j<=m;j++)
                            s[j].insert(i);
                    }
                }
            }else if(a[i]>0){
                if(u[i]>v){
                    int l=lower_bound(csy+1,csy+1+m,d[i])-csy;
                    if(csy[l]>=d[i]){
                        ans++;
                        for(int j=l;j<=m;j++)
                            s[j].insert(i);
                    }
                }else{
                    double len=(v*v-u[i]*u[i])/2/a[i];
                    int l=upper_bound(csy+1,csy+1+m,d[i]+len)-csy;
                    if(csy[l]>=d[i]){
                        ans++;
                        for(int j=l;j<=m;j++)
                            s[j].insert(i);
                    }
                }
            }else{
                if(u[i]>v){
                    double len=(v*v-u[i]*u[i])/2/a[i];
                    int l=lower_bound(csy+1,csy+1+m,d[i])-csy;
                    int r=upper_bound(csy+1,csy+1+m,d[i]+len)-csy-1;
                    if(csy[l]>=d[i]&&csy[r]<=d[i]+len&&l<=r){
                        ans++;
                        for(int j=l;j<=r;j++)
                            s[j].insert(i);
                    }
                }
            }
        }dfs(0,0,0);
        cout<<ans<<' '<<m-num<<"\n";
    }
}
